<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>作品管理</title>
    <link rel="icon" href="../../img/logoimg.png" type="image/ico">
</head>
<script type="text/javascript" src="../../js/jquery-3.6.0.min.js"></script>
<style>
    a {
        color: green;
        text-decoration: none;
    }
</style>
<div th:include="common/style"></div>
<body style="background: #f7f1e3;">
<br>
<input type="button" value="创建作品" style="border-radius: 5px; height: 30px; width: auto;" th:onclick="|toAddBookList(${application.user.uId})|" class="btn-primary">
    <table border="2" style="width: 80%; text-align: center; margin-top: 5%;">
        <tr style="background: black; color: white;">
            <td>作品</td>
            <td>类型</td>
            <td>进度</td>
            <td>签约状态</td>
            <td>发表时间</td>
            <td>操作</td>
        </tr>
        <tr th:each="b1:${bookList}">
            <td>
                <a th:text="${b1.blName}" th:href="@{chapterManager(bookid=${b1.blId},bookname=${b1.blName})}"></a>
            </td>
            <td th:text="${b1.type.tName}"></td>
            <td th:if="${b1.blSpeed == 1}" th:text="连载中"></td>
            <td th:if="${b1.blSpeed == 0}" th:text="已完结" style="color: green"></td>
<!--            <td >字数</td>-->
            <td th:if="${b1.blSignstatus == 1}" >未签
                <input class="btn-primary" type="button" value="申请签约" style="color: red;" th:onclick="|applyQianyue(${b1.blId})|">
            </td>
            <td th:if="${b1.blSignstatus == 2}" th:text="已申请签约" style="color: green"></td>
            <td th:if="${b1.blSignstatus == 3}" th:text="已签" style="color: red"></td>
            <td th:if="${b1.blSignstatus == 4}" >签约未通过
                <input class="btn-primary" type="button" value="再次申请" style="color: red;" th:onclick="|applyQianyue(${b1.blId})|">
            </td>
            <td th:text="${b1.blDate}"></td>
            <td>
                <input class="btn-primary" type="button" value="删除" th:onclick="|delBook(bookid=${b1.blId})|">
            </td>
        </tr>
    </table>
</body>
<script>

    function delBook(bookid){
        location.href = "delBook?bookid=" + bookid;
    }
    function applyQianyue(blId){
        $.ajax({
            url:"applyQianyue",
            type:"post",
            data:{"blId":blId},
            success:function (){
                alert("您已提交签约申请");
            },error:function (){
                alert("申请失败，请重试");
            }
        })
    }
    function toAddBookList(uId){
        location.href="/author/toAddBookList?uId="+uId;
    }
</script>
</html>